{% include 'layout.html' %}

<div class="container">
    <div class="card">
        <div class="card-header">
            Let's edit your todo!
        </div>
        <div class="card-body">
            <form method="POST">
                <div class="form-group">
                    <label>Title</label>
                    <input type="text" class="form-control" name="title" value="{{todo.title}}" required>
                </div>
                <div class="form-group">
                    <label>Description</label>
                    <textarea name="description" class="form-control" rows="3" required>{{todo.description}}</textarea>
                </div>
                <div class="form-group">
                    <label>Priority</label>
                    <select name="priority" class="form-control">
                        <option {% if todo.priority == 1%} selected="selected" {% endif %}>1</option>
                        <option {% if todo.priority == 2%} selected="selected" {% endif %}>2</option>
                        <option {% if todo.priority == 3%} selected="selected" {% endif %}>3</option>
                        <option {% if todo.priority == 4%} selected="selected" {% endif %}>4</option>
                        <option {% if todo.priority == 5%} selected="selected" {% endif %}>5</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-primary">Edit your todo</button>
                <button onclick="window.location.href='/todos/delete/{{todo.id}}'"
                        type="button" class="btn btn-danger">Delete</button>
            </form>
        </div>
    </div>
</div>
